package com.d0325.Z25;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class BirthArrayList<T>{
    public static void main(String[] args) throws ParseException {
        Scanner sc=new Scanner(System.in);
        List<Long> myList=new ArrayList<>();
        SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd");
        String birth=null;
        Date date=new Date();
        long time=date.getTime();
        System.out.println("请输入5个人的出生日期:");
        for (int i = 0; i < 5; i++) {
            birth = sc.next();
            birth.split(" ");
            date = sdf1.parse(birth);//将字符串转换成date对象
            long day=(time-date.getTime())/1000/60/60/24;
            System.out.println("据您出生已有:"+day+"天");
            myList.add(day);
        }
        System.out.println("打印ArrayList:");
        System.out.println(myList.subList(0,5));
    }
}
